<?php
require_once('Db.php');
Db::init();

//TODO treba domysliet este aky presne filter treba.

?>
<html>
	<head>		
		<script type="text/javascript" src="prototype.js"></script>
		<script>

			function sendRequest() {
				new Ajax.Request("create_chart.php", 
					{ 
					method: 'post',
					parameters: $('test').serialize(true),
					onComplete: showResponse 
					});
				}

			function showResponse(req){
				$('image').innerHTML= req.responseText;
			}
		</script>
	</head>



	<body><div style="margin-bot">
	
	  <h1>Generovanie charts pre FOSS dotaznik</h1>	
		<form id="test" onsubmit="return false;">
      <h2>Vyber si najskor ktory select pouzit</h2>
      <input type="radio" name="group1" value="1"> Otazka ohladom pouzivania foss<br>
      <input type="radio" name="group1" value="2"> Ano/Nie Otazka <br>
      <input type="text" name="group1"> Ano/Nie Otazka <br>
    	<br><br>  
      <div><label for="kraje">Vyber si kraj:</label>		
		  <select name="kraj" id="kraj">
        <?
           foreach(Db::fetchAll("SELECT * FROM kraj") as $row){
              
               echo '<option value="'.$row['id']. '">'.$row['nazov'].'</option>';
           }
        ?>       
      </select>
      <br>
      <label for="okres">Vyber si okres:</label>
       		
      <select name="okres" id="okres">
        <?
           foreach(Db::fetchAll("SELECT * FROM okres") as $row){
              
               echo '<option value="'.$row['id']. '">'.$row['nazov'].'</option>';
           }
        ?>
                
      </select>
      <br>
      <label for="okres">Vyber si typ organizacie:</label>		
      <select name="org" id="org">
          <option value="1">Statne skoly</option>
          <option value="2">Sukromne skoly</option> 
          <option value="3">Cirkevne skoly</option>  
      </select>
      
      
      <br>
			<input type="submit" value="submit" onClick="sendRequest()">
		</form>
		</div>
		<div id="image"></div>
	</body>

</html>
